﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace PepsiCo.Intranet.WebParts.DocumentLibraryTreeView
{
    [ToolboxItemAttribute(false)]
    public class DocumentLibraryTreeView : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/PepsiCo.Intranet.WebParts/DocumentLibraryTreeView/DocumentLibraryTreeViewUserControl.ascx";

        /// <summary>
        ///
        /// </summary>
        public DocumentLibraryTreeView()
        {

        }

                /// <summary>
        /// To make Configuration in the webpart properties pane
        /// </summary>
        public string _DocumentLibrary;
        [Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Document Library Name"),
        WebDescription("Please specify the document library name")]
        public string DocumentLibrary
        {
            get { return _DocumentLibrary; }
            set { _DocumentLibrary = value; }
        }

        /// <summary>
        /// To make Configuration in the webpart properties pane
        /// </summary>
        public string _DocumentLibraryFolderPath;
        [Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Document Library Folder Path (ex: /Folder 1/Subfolder 2)"),
        WebDescription("Please specify the document library folder path")]
        public string DocumentLibraryFolderPath
        {
            get { return _DocumentLibraryFolderPath; }
            set { _DocumentLibraryFolderPath = value; }
        }

        /// <summary>
        /// This custom property is for showing the tree view structure as only folder/ or with Folders/Files
        /// </summary>
        public Boolean _IsOnlyFolders;
        [Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Only Folder structures"),
        WebDescription("Please check whether need only Folder structure or with files")]
        public Boolean IsOnlyFolders
        {
            get { return _IsOnlyFolders; }
            set { _IsOnlyFolders = value; }
        }

        /// <summary>
        /// This propery is to show the documents in the tree view according to the currently
        /// logged user.
        /// </summary>
        public Boolean _IsLoginUser;
        [Category("Configuration"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Related Login user"),
        WebDescription("Please specify the documents related to current login user")]
        public Boolean IsLoginUser
        {
            get { return _IsLoginUser; }
            set { _IsLoginUser = value; }
        }

        /// <summary>
        ///
        /// </summary>
        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }
    }
}
